home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr10 / inter35c.zip / WINHELP.ZIP / SCANSHOR.AWK < prev    next >
Text File  |  1993-02-12  |  5KB  |  118 lines

  1.  
  2. BEGIN{
  3. # following two constants are meant to be modified if need arises
  4.  
  5.    ln_limit = 20
  6. # up to this long into pop-up, \footnote lines are also
  7. # counted. Target system's display mode effects this value
  8. # 20 seems quite good with 800x600 resolution
  9.  
  10.    awklim = 100
  11. # you can try bigger value, it speeds up but all awks seem to be limited to
  12. # about 100. This really makes the whole operation rather silly. Some awks
  13. # might die rather ugly death. 100 seems safe enough. If awk runs with bigger
  14. # value it is ok to use it.
  15.  
  16.    newnr = 0
  17.    newtopic = "^A$"       # kludge to avoid "" in first sub line in mkpp0.awk
  18.    outline = 0
  19.    outend  = 0
  20.    outstem = "mkpp"
  21.    outfile = outstem outend ".awk"
  22.    tmpflip = 1
  23.  
  24.    print "BEGIN{\n"                                             >> outfile
  25.    print "disloc = - 1"                                         >> outfile
  26.    print "FS = \"{\""                                           >> outfile
  27.    print "OFS = \"{\""                                          >> outfile
  28.    print "}\n"                                                  >> outfile
  29.    print "{\n"                                                  >> outfile
  30.    print "if (($2 ~ /[Ss]ee[Aa]lso/) || (skip == \"off\")){"    >> outfile
  31.    printf("  for(i=2; i <= NF; i++){\n ")                       >> outfile
  32.    print "mawk -f " outfile " intrtf.bot > %tmp%\intrtf.bo1 " >> "ppscan.bat"
  33.    print "mawk -f " outfile " skip=off intrtf.idx > %tmp%\intrtf.id1 " >> "ppscan.bat"
  34.    print "mawk -f " outfile " skip=off intrtf.byf > %tmp%\intrtf.bf1 " >> "ppscan.bat"
  35.    print "mawk -f " outfile " skip=off intrtf.byv > %tmp%\intrtf.bv1 " >> "ppscan.bat"
  36.  
  37.  
  38. }
  39.  
  40. { if ($0 ~ /^\#{/){
  41.    oldnr = newnr;
  42.    newnr = NR;
  43.    if (ln_limit < (newnr - oldnr)){
  44.       outline++
  45.       if (outline > awklim ){
  46.          outline = 0;
  47.          outend++
  48.          print "}" >> outfile
  49.          print "}" >> outfile
  50.          print "\n print $0 \n" >> outfile
  51.          print "\n}\n" >> outfile
  52.          close(outfile)
  53.          outfile = outstem outend ".awk"
  54.          if (tmpflip){
  55.             print "mawk -f " outfile " %tmp%\intrtf.bo1 > %tmp%\intrtf.bo2 " >> "ppscan.bat"
  56.             print "mawk -f " outfile " skip=off %tmp%\intrtf.id1 > %tmp%\intrtf.id2 " >> "ppscan.bat"
  57.             print "mawk -f " outfile " skip=off %tmp%\intrtf.bv1 > %tmp%\intrtf.bv2 " >> "ppscan.bat"
  58.             print "mawk -f " outfile " skip=off %tmp%\intrtf.bf1 > %tmp%\intrtf.bf2 " >> "ppscan.bat"
  59.             tmpflip = 0
  60.             }
  61.          else{
  62.             print "mawk -f " outfile " %tmp%\intrtf.bo2 > %tmp%\intrtf.bo1 " >> "ppscan.bat"
  63.             print "mawk -f " outfile " skip=off %tmp%\intrtf.id2 > %tmp%\intrtf.id1 " >> "ppscan.bat"
  64.             print "mawk -f " outfile " skip=off %tmp%\intrtf.bv2 > %tmp%\intrtf.bv1 " >> "ppscan.bat"
  65.             print "mawk -f " outfile " skip=off %tmp%\intrtf.bf2 > %tmp%\intrtf.bf1 " >> "ppscan.bat"
  66.             tmpflip = 1
  67.          }
  68.          print "BEGIN{\n"                                             >> outfile
  69.          print "FS = \"{\""                                           >> outfile
  70.          print "OFS = \"{\""                                           >> outfile
  71.          print "disloc = - 1"                                         >> outfile
  72.          print "}\n"                                                  >> outfile
  73.          print "{\n"                                                  >> outfile
  74.          print "if (($2 ~ /[Ss]ee[Aa]lso/) || (skip == \"off\")){"    >> outfile
  75. #        print "if ($1 ~ /[Ss]ee[Aa]lso/){"                           >> outfile
  76.          printf("  for(i=2; i <= NF; i++){\n ")                             >> outfile
  77.          }
  78.       topicbeg = index($0, " _") + 1
  79.       topicend = index($0 , "Z }") + 1
  80. # debugline      print topicbeg " = topicbeg   " topicend " = topicend   " newnr " = newnr  " (newnr - oldnr) " = diff"
  81.       topic = newtopic
  82.       newtopic = substr($0, topicbeg, topicend - topicbeg)
  83.  
  84.       printf("      if ($i ~ \"%s\"){ sub(\"db\", \"\", $(i+disloc)); i++; continue}\n", topic)  >> outfile
  85.       }
  86.    }
  87. }
  88. END{
  89.    print "}" >> outfile
  90.    print "}" >> outfile
  91.    print "\n print $0 \n" >> outfile
  92.    print "\n}\n" >> outfile
  93.    close(outfile)
  94.    if (tmpflip){
  95.       print "copy %tmp%\intrtf.bo1  intrtf.bot " >> "ppscan.bat"
  96.       print "copy %tmp%\intrtf.id1  intrtf.idx " >> "ppscan.bat"
  97.       print "copy %tmp%\intrtf.bv1  intrtf.byv " >> "ppscan.bat"
  98.       print "copy %tmp%\intrtf.bf1  intrtf.byf " >> "ppscan.bat"
  99.       }
  100.    else{
  101.       print "copy %tmp%\intrtf.bo2  intrtf.bot " >> "ppscan.bat"
  102.       print "copy %tmp%\intrtf.id2  intrtf.idx " >> "ppscan.bat"
  103.       print "copy %tmp%\intrtf.bv2  intrtf.byv " >> "ppscan.bat"
  104.       print "copy %tmp%\intrtf.bf2  intrtf.byf " >> "ppscan.bat"
  105.    }
  106.    print "del %tmp%\intrtf.bo2"       >> "ppscan.bat"
  107.    print "del %tmp%\intrtf.bo1"       >> "ppscan.bat"
  108.    print "del %tmp%\intrtf.id1"       >> "ppscan.bat"
  109.    print "del %tmp%\intrtf.id2"       >> "ppscan.bat"
  110.    print "del %tmp%\intrtf.bv1"       >> "ppscan.bat"
  111.    print "del %tmp%\intrtf.bv2"       >> "ppscan.bat"
  112.    print "del %tmp%\intrtf.bf1"       >> "ppscan.bat"
  113.    print "del %tmp%\intrtf.bf2"       >> "ppscan.bat"
  114.    close("ppscan.bat")
  115.  
  116. }
  117.  
  118.